package com.mydesignpattern.beijing.strategy;

/**
 * 环境context类
 */
public class Traveler {

    //出行策略接口
    TravelStrategy travelStrategy;
    //设置出行策略
    public void setTravelStrategy(TravelStrategy travelStrategy){
        this.travelStrategy = travelStrategy;
    }

    //具体的业务逻辑调用
    public static void main(String[] args){
        Traveler traveler = new Traveler();
        //设置出行策略
        traveler.setTravelStrategy(new TrainStrategy());
        //traveler.setTravelStrategy(new AirStrategy());
        //traveler.setTravelStrategy(new CarStrategy());
        //游客出行
        traveler.travel();
    }


    public void travel(){
        travelStrategy.travelStyle();
    }

}
